# Contributor: Seth Schroeder <theking@kingdomofseth.com>

pkgname=leocad
pkgver=0.79.2
_piecesver=7114
pkgrel=3
pkgdesc="LeoCAD is a CAD program for creating virtual LEGO models. It has an easy to use interface and currently includes over 6000 different pieces created by the  LDraw community."
arch=(i386, x86_64)
url="http://leocad.org"
license=('GPL')
depends=('zlib' 'libjpeg' 'libpng' 'gtk2' 'mesa')
makedebends=('patch')
install=${pkgname}.install
source=("http://leocad.googlecode.com/files/${pkgname}-${pkgver}-src.tgz" "http://leocad.googlecode.com/files/pieces-${_piecesver}.zip" http://leocad-arch.googlecode.com/files/leocad-aur-patches-${pkgver}.tar.gz)
md5sums=('8281315c34d9542eae7b94ec88d31937'
         '5be3590d960c546edf1d4dcb72dba7c1'
	 '6d40c3978733165ee40b371ebd61c572')

build() {
  msg "Building LeoCAD"
  msg "Applying Arch-speceific-patches"
  patch -i ${srcdir}/Makefile.patch ${srcdir}/leocad/Makefile
  patch -i ${srcdir}/module.mk.patch ${srcdir}/leocad/common/module.mk
  mkdir -p ${pkgdir}/usr/lib/pieces/
  cd ${srcdir}/${pkgname}
  make
}

package(){
  cd ${srcdir}/${pkgname}
  make DESTDIR=${pkgdir} install
  msg "Installing libraries"
  install -Dm644 ${srcdir}/*.bin ${pkgdir}/usr/lib/pieces/
  #install -Dm644 ${srcdir}/*.idx ${pkgdir}/usr/lib/pieces/
  #install -Dm644 ${srcdir}/*.txf ${pkgdir}/usr/lib/pieces/
}
